package com.example.service.serviceImpl;

import com.example.domain.User;
import com.example.mapper.UserMapper;
import com.example.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    UserMapper userMapper;

    @Override
    public List<User> selectUserById(Integer id) {
        return userMapper.selectUserById(id);
    }

    @Override
    public String selectUnameById(Integer id) {
        return userMapper.selectNameById(id);
    }

    @Override
    public List<String> selectUname() {
        return userMapper.selectUname();
    }

    @Override
    public User selectLimitById(Integer id) {
        return userMapper.selectLimitById(id);
    }

    @Override
    public Integer selectIdByUname(String uname) {
        return userMapper.selectIdByUname(uname);
    }

    @Override
    public List<User> selectUser(String object) throws Exception {
        return userMapper.selectUser(object);
    }

    @Override
    public List<User> searchUserByAll(Integer id,String name) throws Exception {
        return userMapper.searchUserByAll(id,name);
    }

    @Override
    public List<User> selectUidByUname(String name) {
        return userMapper.selectUidByUname(name);
    }

    @Override
    public List<User> showAllUser() {
        return userMapper.showAllUser();
    }

    @Override
    public Boolean updateUser(String uid,String uname)throws Exception {
        return userMapper.updateUser(uid,uname);
    }

    @Override
    public Boolean InsertUser(String uid,String uname) throws Exception{
        return userMapper.insertUser(uid,uname);
    }

    @Override
    public Boolean hasId(String uid) throws Exception{
        int result = userMapper.hasId(uid);
        System.out.println("result:"+result);
        if (result>0){
            System.out.println("结果："+(userMapper.hasId(uid)).equals(0));
            return false;
        }else{
            System.out.println("结果："+(userMapper.hasId(uid)).equals(0));
            return true;
        }
    }

    @Override
    public Boolean deleteUser() {
        return userMapper.deleteUser();
    }

    @Override
    public Boolean addManager(Integer id) {
        return userMapper.addManager(id);
    }

    @Override
    public Boolean removeManger(Integer id) {
        return userMapper.removeManger(id);
    }

    @Override
    public List<User> showManager() {
        return userMapper.showManager();
    }
}
